FROM golang:1.17-alpine3.14 as build

# 将 go-study(目录)中的所有文件复制到  /go/go-study 也可以加/ /go/go-study/
# 如果是复制文件就要加/ ,否则就文件名就变成go-study   /go/go-study/
# COPY更清晰，ADD会解压
COPY go-study /go/go-study
WORKDIR /go/go-study
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn \
    CGO_ENABLED=0

RUN go build webserver/WebServer.go


FROM alpine:3.14
COPY --from=build /go/go-study/WebServer /WebServer
WORKDIR /
# 设置时区
ENV TZ=Asia/Shanghai
RUN apk add -U tzdata && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

EXPOSE 8899
ENTRYPOINT ["/WebServer"]



